<%--
  Created by IntelliJ IDEA.
  User: Chen
  Date: 2016/3/23
  Time: 16:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fns" uri="/WEB-INF/tlds/fns.tld" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />
<h4>所有选题</h4>
<form class="form-inline well" role="form" id="search-form">
    <div class="form-group">
        <label for="creator">出题人 :</label>
        <input class="form-control input-sm" id="creator" name="creator" size="30" type="text">
    </div>
    <button type="button" class="btn btn-primary btn-sm btn-search-submit">确认</button>
    <a href="${ctx }/teacher/choice/manage" class="btn btn-default btn-sm">刷新</a>
</form>

<div id="list-data"></div>

<script id="list-template" type="text/html">
    {{if totalCount == 0}}<p style="font-size: larger;">暂时没有待审核的选题!</p>{{/if}}
    {{if totalCount != 0}}
    <table id="choice-table" class="table table-bordered table-hover ">
        <thead>
        <tr>
            <th width="25%;">题目</th>
            <th>类型</th>
            <th>选题学生</th>
            <th>出题人</th>
            <th>指导老师</th>
            <th>选题时间</th>
            <th>是否通过</th>
            <th>状态</th>
        </tr>
        </thead>
        <tbody>
        {{each result as value i}}
        <tr>
            <td style="font-size: larger">{{if value.topic != null}}{{ value.topic.name }}{{/if}}</td>
            <td>
                <c:forEach items="${fns:getDictList('topic_type')}" var="dict">
                    {{if value.topic.type == '${dict.value}' }}${dict.label}{{/if}}
                </c:forEach>
            </td>
            <td>{{if value.student != null}}{{value.student.name}}{{/if}}</td>
            <td>{{if value.topic != null && value.topic.creator != null}}{{ value.topic.creator.name }}{{/if}}</td>
            <td>{{if value.topic != null && value.topic.directTeacher != null}}{{ value.topic.directTeacher.name }}{{/if}}</td>
            <td>{{ value.choiceDate }}</td>
            <td>
                <c:forEach items="${fns:getDictList('topic_pass')}" var="dict">
                    {{ if value.status == '${dict.value}' }}
                    {{if value.status == 0}}<span class="label label-default">${dict.label}</span>{{/if}}
                    {{if value.status == 1}}<span class="label label-success">${dict.label}</span>{{/if}}
                    {{if value.status == 2}}<span class="label label-danger">${dict.label}</span>{{/if}}
                    {{if value.status == 3}}<span class="label label-primary">${dict.label}</span>{{/if}}
                    {{if value.status == 4}}<span class="label label-warning">${dict.label}</span>{{/if}}
                    {{if value.status == 5}}<span class="label label-default">${dict.label}</span>{{/if}}
                    {{/if}}
                </c:forEach>
            </td>
            <td>
                <c:forEach items="${fns:getDictList('del_flag_type')}" var="dict">
                    {{if value.delFlag == '${dict.value}'}}
                    {{if value.delFlag == 0}}<span class="label label-success">${dict.label}</span>{{/if}}
                    {{if value.delFlag == 1}}<span class="label label-default">${dict.label}</span>{{/if}}
                    {{/if}}
                </c:forEach>
            </td>
            <td>
                <a data-toggle="modal" data-target="#myModal" class="btn topic-details" value="{{ value.id }}"><span class="glyphicon glyphicon-search"></span>
                    查看
                </a>
                <a class="btn-link choice-pass" data='{"id":"{{ value.id }}"}'><span class="glyphicon glyphicon-ok"></span>通过</a>
                <a class="btn-link choice-nopass" data='{"id":"{{ value.id }}"}'><span class="glyphicon glyphicon-remove"></span>不通过</a>
            </td>
        </tr>
        {{/each}}
        </tbody>
    </table>
    <div>
        {{#pagination }}
    </div>
    {{/if}}
</script>



<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">
                    选题详情
                </h4>
            </div>
            <div class="modal-body">
                <div id="list-data1">
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>

<script id="list-template1" type="text/html">
    <table class="table table-striped table-bordered table-hover">
        <tr>
            <td class="modal_td">题目</td>
            <td>{{if choice.topic != null}}{{ choice.topic.name }}{{/if}}</td>
        </tr>
        <tr>
            <td class="modal_td">类型</td>
            <td>
                <c:forEach items="${fns:getDictList('topic_type')}" var="dict">
                    {{ if choice.topic.type == '${dict.value}' }}${dict.label}{{/if}}
                </c:forEach>
            </td>
        </tr>
        <tr>
            <td class="modal_td">来源</td>
            <td>
                <c:forEach items="${fns:getDictList('topic_source')}" var="dict">
                    {{ if choice.topic.source == '${dict.value}' }}${dict.label}{{/if}}
                </c:forEach>
            </td>
        </tr>
        <tr>
            <td class="modal_td">选题时间</td>
            <td>{{ choice.choiceDate }}</td>
        </tr>
        <tr>
            <td class="modal_td">选题学生</td>
            <td>{{ choice.student.name }}</td>
        </tr>
        <tr>
            <td class="modal_td">出题人</td>
            <td>{{if choice.topic.creator != null}}{{ choice.topic.creator.name }}{{/if}}</td>
        </tr>
        <tr>
            <td class="modal_td">指导老师</td>
            <td>{{if choice.topic.directTeacher != null}}{{ choice.topic.directTeacher.name }}{{/if}}</td>
        </tr>
        <tr>
            <td class="modal_td">描述</td>
            <td>{{ choice.topic.description }}</td>
        </tr>
        <tr>
            <td class="modal_td">状态</td>
            <td>
                <c:forEach items="${fns:getDictList('topic_pass')}" var="dict">
                    {{ if choice.topic.pass == '${dict.value}' }}${dict.label}{{/if}}
                </c:forEach>
            </td>
        </tr>
    </table>
</script>



<script type="text/javascript">
    <c:if test="${env == 'pro' }">
    requirejs(['${ctx}/assets/js/app/teacher/choice-manage-page.js']);
    </c:if>
    <c:if test="${env != 'pro' }">
    requirejs(['${ctx}/assets/js/app/teacher/choice-manage-page.js']);
    </c:if>
</script>
